
DEFAULT_FIELDSETS =   [ ("基本", {'fields':("userid",("username", "city", "phone"), ("email", "apply_position", "born_address"), "gender", "candidate_remark", "bachelor_school", "master_school", "doctor_school", "major", "degree", "test_score_of_general_ability", "paper_score", "last_editor",)})]
FIRST_FIELDSETS = [ ("一面", {'fields':("first_score", "first_learning_ability", "first_professional_competency", "first_advantage", "first_disadvantage", "first_result", "first_recommend_position", "first_interviewer_user", "first_remark",)}) ]
SECOND_FIELDSETS = [  ("二面", {'fields': ("second_score", "second_learning_ability", "second_professional_competency", "second_pursue_of_excellence", "second_communication_ability", "second_pressure_score", "second_advantage", "second_disadvantage", "second_result", "second_recommend_position", "second_interviewer_user", "second_remark",)})]
HR_FIELDSETS = [("HR面", {'fields': ("hr_score", "hr_responsibility", "hr_communication_ability", "hr_logic_ability", "hr_potential", "hr_stability", "hr_advantage", "hr_disadvantage", "hr_result", "hr_interviewer_user", "hr_remark",)})]

DEFAULT_LIST_DISPLAY = (
    'username', 'city', 'bachelor_school', 'first_score', 'first_result', 'first_interviewer_user', 'second_score',
    'second_result', 'second_interviewer_user', 'hr_score', 'hr_result', 'hr_interviewer_user',)

INTERVIEWER_LIST_DISPLAY = ('username', 'city', 'bachelor_school', 'first_score', 'first_result', 'first_interviewer_user','second_interviewer_user')

def get_detailpage_fieldsets(user, obj ):
    group_names = [x.name for x in user.groups.all()]
    if 'hr' in group_names or user.is_superuser:
        return DEFAULT_FIELDSETS + FIRST_FIELDSETS + SECOND_FIELDSETS + HR_FIELDSETS
    elif 'interviewer' in group_names and obj.second_interview_user == user:
        return DEFAULT_FIELDSETS + FIRST_FIELDSETS + SECOND_FIELDSETS
    elif 'interviewer' in group_names and obj.first_interview_user == user:
        return DEFAULT_FIELDSETS + FIRST_FIELDSETS
    else:
        return DEFAULT_FIELDSETS


def get_listdisplay_fields(user):
    group_names = [x.name for x in user.groups.all()]
    if 'hr' in group_names or user.is_superuser:
        return DEFAULT_LIST_DISPLAY
    else:
        return INTERVIEWER_LIST_DISPLAY
